package com.example.hellodemo.recyclerView;

import android.content.Context;
import android.content.IntentFilter;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.example.hellodemo.R;

import org.w3c.dom.Text;

public class LinearHRCyclerAdapter extends RecyclerView.Adapter<LinearHRCyclerAdapter.HRViewHolder> {
    private Context context;
    private ItemOnCLick itemOnClick;
    public  LinearHRCyclerAdapter(Context context,ItemOnCLick itemOnClick){
        this.context = context;
        this.itemOnClick = itemOnClick;
    }

    @NonNull
    @Override
    public HRViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {

        return new HRViewHolder(LayoutInflater.from(context).inflate(R.layout.rhcycleview_tiem,parent,false));
    }

    @Override
    public void onBindViewHolder(@NonNull HRViewHolder holder, final int position) {
            holder.titleView.setText("横向滑动");
            holder.itemView.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    itemOnClick.onclick(position);
                }
            });
    }

    @Override
    public int getItemCount() {
        return 10;
    }

    class HRViewHolder extends RecyclerView.ViewHolder{
        private TextView titleView;
        public  HRViewHolder(View view){
            super(view);
            this.titleView = view.findViewById(R.id.hr_textView);
        }

    }

    interface  ItemOnCLick{
        public void onclick(int position);
    }
}
